package sweetvsti;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import jvst.wrapper.VSTPluginAdapter;
import jvst.wrapper.gui.VSTPluginGUIRunner;

/**
 * SweetGUIにNimbusのL&Fを付けただけのクラス
 * @author uimac
 */
public class NimbusSweetGUI extends SweetGUI {

    private static final long serialVersionUID = 4234216957645164799L;

    /**
     * NimbusのL&Fを付ける
     */
    private void applyLookAndFeel() {
        //TELL the UI Manager that it should use the Plugins ClassLoader to load UI classes.
        UIManager.put("ClassLoader", this.getClass().getClassLoader());

        //use the napkin look-and-feel for this plugin!
        try {
            UIManager.setLookAndFeel(
                    "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (UnsupportedLookAndFeelException e) {
            // 無視
        } catch (ClassNotFoundException e) {
            // 無視
        } catch (InstantiationException e) {
            // 無視
        } catch (IllegalAccessException e) {
            // 無視
        }
        SwingUtilities.updateComponentTreeUI(this);
    }

    public NimbusSweetGUI(VSTPluginGUIRunner r, VSTPluginAdapter plugin) throws Exception {
        super(r, plugin);
        applyLookAndFeel();
    }

    public NimbusSweetGUI() {
        super();
        applyLookAndFeel();
    }


    /**
     * GUI表示テスト用メイン
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        TestWave vsti = new TestWave();
        SweetGUI gui = new NimbusSweetGUI();
        gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        gui.open();
    }
}
